package io.afu.nginxhelper.dto.common.upstream;

import io.afu.nginxhelper.constant.NgxConst;

import java.util.List;

/**
 * @author RffanLAB.方露宇
 * @version 0.1
 */
public class Upstream {

    public static final String HASH = "hash";
    public static final String IP_HASH = "ip_hash";

    public static final String KEY = "";

    /**
     * 名称
     */
    private String name;

    public String workType;

    List<UpServer> servers;

    private String keepalive;

    private boolean hashEnabled;

    private boolean ipHashEnabled;

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (hashEnabled){
            sb.append(Upstream.HASH)
                    .append(NgxConst.END_MARK)
                    .append(NgxConst.NEW_LINE);
        }
        if (ipHashEnabled){
            sb.append(Upstream.IP_HASH)
                    .append(NgxConst.END_MARK)
                    .append(NgxConst.NEW_LINE);
        }


        return super.toString();
    }
}
